package com.fbee.smartcommunities.controller;

import com.fbee.smartcommunities.entity.Advertising;
import com.fbee.smartcommunities.service.AdvertisingService;
import com.fbee.smartcommunities.vo.ResultVO;
import io.minio.errors.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.sql.Array;
import java.util.List;

/**
 * <p>
 * 轮播图广告表 前端控制器
 * </p>
 *
 * @author 汪佳泉
 * @since 2024-08-18
 */
@RestController
@RequestMapping("/advertising")
public class AdvertisingController {

    @Resource
    private AdvertisingService advertisingService;

    @GetMapping("/getPictures")
    public ResultVO<List<Advertising>> getPictures(){
        return ResultVO.success(advertisingService.list());
    }

    @PostMapping("/update")
    public ResultVO<Boolean> update(Long id, MultipartFile file) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
       return ResultVO.success(advertisingService.updateImg(id,file));
    }

}
